//
//  WBNetwork+Extension.swift
//  weibo
//
//  Created by 李海超 on 2017/5/30.
//  Copyright © 2017年 lihaichao. All rights reserved.
//

import Foundation















//封装新浪微博的请求方法
extension WBNetworkManager{
    
    
    //获取首页微博数据的网络请求
    //sin_id返回最新的数据
    //max_id返回旧的数据
    func statusList(since_id:Int64 = 0,max_id:Int64 = 0,comlete:@escaping ([[String:Any]],Bool)->()){
        let urlString = "https://api.weibo.com/2/statuses/home_timeline.json"
        
        let parameters = ["since_id":"\(since_id)","max_id":"\(max_id>0 ? max_id-1 : 0)"]
        
        accessTokenRequest(URLString: urlString, parameters: parameters) { (json, IsSuccess) in
            guard let json = json as? Dictionary<String, Any>,
            let list = json["statuses"] as? Array<[String:Any]>
                else{
                return
            }
            comlete(list, IsSuccess)
        }

    }
    

}











